package io.renren.common.jackson;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;

import java.io.IOException;

/**
 * 针对空对象的处理
 *
 * @author 40659
 * @since 2025/2/14 13:40
 */
public class NullObjectJsonSerializer extends JsonSerializer<Object> {

    /**
     * 声明为单例模式
     */
    public static final NullObjectJsonSerializer INSTANCE = new NullObjectJsonSerializer();

    @Override
    public void serialize(Object value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
        gen.writeString("");
    }
}
